package com.tianji.learning.controller;


import com.tianji.api.dto.leanring.LearningLessonDTO;
import com.tianji.api.dto.leanring.LearningRecordDTO;
import com.tianji.api.dto.leanring.LearningRecordFormDTO;
import com.tianji.learning.domain.vo.LearningLessonVO;
import com.tianji.learning.service.ILearningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学习记录表 前端控制器
 * </p>
 *
 * @author 丁真
 * @since 2025-06-28
 */
@Api(tags = "学习记录相关接口")
@RestController
@RequestMapping("/learning-records")
@RequiredArgsConstructor
public class LearningRecordController {
    private static final Logger log = LoggerFactory.getLogger(LearningRecordController.class);
    private final ILearningRecordService recordService;

    /**
     * 查询当前用户指定课程的学习进度
     *
     * @param courseId 课程id
     * @return 课表信息、学习记录及进度信息
     */
    @ApiOperation("查询当前用户指定课程的学习进度")
    @GetMapping("/course/{courseId}")
    LearningLessonDTO queryLearningRecordByCourse(@PathVariable("courseId") Long courseId) {
        log.info("查询当前用户指定课程{}的学习进度",courseId);
        return recordService.queryLearningRecordByCourse(courseId);
    }

    /**
     * 提交学习记录
     *
     */
    @ApiOperation("提交学习记录")
    @PostMapping()
    void submitLearningRecord(@RequestBody LearningRecordFormDTO recordDTO) {
        log.info("提交学习记录");
        recordService.submitLearningRecord(recordDTO);
    }

}
